{include file="public/header" /}
<body>
<div class="layui-tab layui-tab-brief main-tab-container">
  <ul class="layui-tab-title main-tab-title">
    <a href="{:url('Links/lst')}"><li class="layui-this">友链列表</li></a>
    <a href="{:url('Links/add_link')}"><li>添加友链</li></a>
    <div class="main-tab-item">友链管理</div>
  </ul>
  <div class="layui-tab-content">
    <div class="layui-tab-item layui-show">
      <form class="layui-form" name="paixu" method="post" onsubmit="return false;">

        <table class="list-table">
          <thead>
          <tr>
            <th>ID</th>
            <th>友链名称</th>
            <th>创建时间</th>
            <th>修改时间</th>
            <th>状态</th>
            <th>操作</th>
          </tr>
          </thead>

          <tbody>
            {volist name="lst" id="vo"}
              <tr>
                <td>{$vo.id}</td>
                <td>{$vo.name}</td>
                <td>{$vo.create_time|default=time()|date='Y-m-d  H:i:s',###}</td>
                <td>{$vo.update_time|default=time()|date='Y-m-d  H:i:s',###}</td>
                {if condition="$vo['status'] == 1"}
                <td><span style="background-color: #23c6c8;color: #FFF;font-size: 10px;font-weight: 500;padding: 3px 8px;border-radius: .25em;">开启</span></td>
                {else/}
                <td><span style="background-color: #ed5565;;color: #FFF;font-size: 10px;font-weight: 500;padding: 3px 8px;border-radius: .25em;">禁用</span></td>
                {/if}
                <td style="text-align: center;">
                  <a href="{:url('edit_link',array('id'=>$vo['id']))}" class="layui-btn layui-btn-small" title="编辑"><i class="layui-icon"></i></a>
                  <a class="layui-btn layui-btn-small layui-btn-danger del_btn" category-id="1" title="删除" id="{$vo.id}"><i class="layui-icon"></i></a>
                </td>
              </tr>
            {/volist}
          </tbody>
    </table>
    </form>
  </div>
</div>
</div>
<script type="text/javascript">
    //删除操作
    $(".del_btn").click(function(){
        var $this = $(this)
        var id=$this.attr('id');
        $.ajax({
            url: "{:url('links/del_link')}",
            data: {'id':id},
            type: "POST",
            datatype:"json",
            success: function( result ) {
                $this.parents('tr').remove();
                layer.open({
                    title: '信息'
                    ,content: '删除成功！'
                });
            }
        });
    });
    layui.use(['element', 'layer', 'form'], function(){
        var element = layui.element()
            ,jq = layui.jquery
            ,form = layui.form()
            ,laypage = layui.laypage;

    })
</script>
</body>
</html>